Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

140
Vistas
How does the loading of an image with "?random=" attached work?

So, I wanted to avoid the cache to see images I'm uploading to this website I'm working on, which I access through localhost.

I hit a handy solution pretty quick:

Attaching to the end of image's path ?random= and a random number generated by Math.floor(). All this with the help of a script.

The HTML showed in the browser:

<img class="gallery_img" src="./uploads/4.jpg?random=172">

Awesome, it works beautifully.

Now, the thing that has been hard to find is an explanation of why and how this actually works.

I mean, 1) how the browser still finds the image in the server with this new path?

Or asked the other way around, 2) how the server handles this ?random=172 attachment and delivers the image asked before that?

If somebody could point me to the right direction I would be grateful.


Solution:

Have a look on what are query parameters.

And if you are dealing with the problem of avoiding the cache, have a look here:

Disable cache for some images

almost 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

That is not part of the path, that is a query parameter.

And most of the times the server of images does not care about query parameters, at least not a literally random one, maybe it would support a query parameter called width or size and dynamically generate an image of the correct size. But random is most likely simply discarded and the image is served normally.

almost 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda